// uni_modules/uni-icons/components/uni-icons/uni-icons.js
import UniconsCss from './unicons.css'
import UIIcons from './unicons_file_vue.js'
import { getConfig } from './TS_unicons_file'

export default {
  name: 'uni-icons',
  mixins: [UIIcons],
  props: {
    type: String,
    color: {
      type: String,
      default: '#999999'
    },
    size: {
      type: [Number, String],
      default: 24
    },
    customPrefix: {
      type: String,
      default: ''
    }
  },
  computed: {
    iconSize() {
      return isNaN(this.size) ? this.size : `${this.size}px`
    },
    iconName() {
      return this.customPrefix ? `${this.customPrefix}-${this.type}` : this.type
    }
  },
  methods: {
    async loadUnicons() {
      try {
        const iconSet = await getConfig()
        this.$options.components.unyicons = iconSet
      } catch (e) {
        console.error('图标加载失败:', e)
      }
    }
  },
  created() {
    this.loadUnicons()
  }
}